package website.lhc.chapter3;

import lombok.extern.slf4j.Slf4j;

/**
 * <p>装饰器模式1</p>
 *
 * @author: longhc@citycloud.com.cn
 * @since: 2022/12/8 16:08
 * @version: 1.0
 */
@Slf4j
public class ClubbedTroll implements Troll {

    private final Troll troll;

    public ClubbedTroll(Troll troll) {
        this.troll = troll;
    }

    @Override
    public void attack() {
        troll.attack();
        log.info("添加额外攻击手段");
    }

    @Override
    public int getAttackPower() {
        int a = 3;
        int b = troll.getAttackPower() + a;
        log.info("添加额外攻击力:{}", a);
        return b;
    }

    @Override
    public void fleeBattle() {
        troll.fleeBattle();
        log.info("do nothing");
    }
}
